[Fix #1569] OneOf builder null value in serialization#1570
Merged
fjtirado merged 2 commits intoJul 24, 2026
Merged
Conversation
…rialization Fix ReferenceableAuthenticationPolicyBuilder and BackoffBuilder calling all OneOf setters unconditionally, which clobbers the value field used by serialization. - Add null guards in ReferenceableAuthenticationPolicyBuilder.build() - Lazy-init backoff objects and add null guards in BackoffBuilder - Add tests verifying OneOfValueProvider.get() returns correct value Signed-off-by: Ricardo Zanini <[email protected]>
ricardozanini
force-pushed
the
fix/1569-oneof-builder-null-value
branch
from
July 23, 2026 16:09
8ca8c80 to
e134543
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a serialization bug where fluent builders for oneOf model types were calling multiple setters unconditionally, causing later null/empty setters to overwrite the internally selected oneOf value and resulting in incorrect OneOfValueProvider.get() output.
Changes:
- Add null-guards in
ReferenceableAuthenticationPolicyBuilder.build()so only the configuredoneOfsetter is invoked. - Lazy-initialize retry backoff variants and only set the configured variant in
BackoffBuilder.build()to avoid empty defaults clobbering theoneOfselection. - Add tests asserting
OneOfValueProvider.get()is non-null and that only the intendedoneOfbranch is populated for authentication and retry backoff.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| fluent/spec/src/main/java/io/serverlessworkflow/fluent/spec/ReferenceableAuthenticationPolicyBuilder.java | Avoids clobbering oneOf value by only setting the non-null authentication option. |
| fluent/spec/src/main/java/io/serverlessworkflow/fluent/spec/BaseTryTaskBuilder.java | Lazy-inits backoff variants and avoids overwriting the selected backoff oneOf value during build. |
| fluent/spec/src/test/java/io/serverlessworkflow/fluent/spec/dsl/CallHttpAuthDslTest.java | Adds regression coverage ensuring authentication oneOf value is set for serialization. |
| fluent/spec/src/test/java/io/serverlessworkflow/fluent/spec/dsl/TryCatchDslTest.java | Adds regression coverage ensuring retry backoff oneOf value is set for serialization. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
fluent/spec/src/main/java/io/serverlessworkflow/fluent/spec/BaseTryTaskBuilder.java:384
BackoffBuilder.build()currently selects the first non-null backoff variant (constant > exponential > linear). If a caller configures more than one variant in the samebackoff(b -> ...)consumer (which the public API allows), the later configuration can be silently ignored (e.g., callingexponential(...)afterconstant(...)will still buildconstantBackoff). SinceRetryBackoffis a oneOf, it would be safer to either (a) fail fast when multiple variants are configured, or (b) ensure the last configured variant wins by clearing the other variants when setting one.
public RetryBackoff build() {
if (this.constantBackoff != null) {
this.retryBackoff.setConstantBackoff(constantBackoff);
} else if (this.exponentialBackOff != null) {
this.retryBackoff.setExponentialBackOff(exponentialBackOff);
BackoffBuilder now throws IllegalStateException when mixing backoff variants (constant, exponential, linear), enforcing the oneOf contract at build time instead of silently picking the first non-null. Signed-off-by: Ricardo Zanini <[email protected]>
fjtirado
approved these changes
Jul 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ReferenceableAuthenticationPolicyBuilder.build()andBackoffBuilder.build()call all OneOf setters unconditionally, causing the last setter (with null/empty) to overwriteOneOfValueProvider.value— leading tonullor wrong values during serialization.build()so only the configured setter is called. Lazy-init backoff objects inBackoffBuilderto avoid empty defaults.OneOfValueProvider.get()returns the correct value.Fixes #1569